<!--
 * @Author: yushuang
 * @Date: 2024-12-03 15:58:14
 * @LastEditors: yushuang
 * @LastEditTime: 2024-12-24 11:27:03
 * @Description: 
-->
<script setup lang="ts">
import { storeToRefs } from 'pinia';
import { useUserStore } from '@/stores/user';
import { LogoutOutlined, ProfileOutlined, UserOutlined } from '@ant-design/icons-vue';
const { avatar, nickname } = storeToRefs(useUserStore());

const handleLogout = () => {
  useUserStore().logout();
};
</script>

<template>
  <a-dropdown>
    <span class="transition-all-300 flex items-center h-[48px] px-[12px] cursor-pointer hover:bg-[var(--hover-color)]">
      <a-avatar :src="avatar" class="mr-[8px]" size="small" />
      <span class="anticon">{{ nickname }}</span>
    </span>
    <template #overlay>
      <a-menu>
        <a-menu-item key="0">
          <template #icon>
            <UserOutlined />
          </template>
          <a target="_blank" rel="noopener noreferrer" href="http://www.alipay.com/"> 个人中心 </a>
        </a-menu-item>
        <a-menu-item key="1">
          <template #icon>
            <ProfileOutlined />
          </template>
          <a target="_blank" rel="noopener noreferrer" href="http://www.taobao.com/"> 个人设置 </a>
        </a-menu-item>
        <a-menu-divider />
        <a-menu-item key="3" @click="handleLogout">
          <template #icon>
            <LogoutOutlined />
          </template>
          退出登录
        </a-menu-item>
      </a-menu>
    </template>
  </a-dropdown>
</template>
